﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SweetSQL.Data.Providers
{
    internal sealed class PsqlSyntaxProvider : SyntaxProviderBase
    {
        private const string PARAM = "?";
        private const char DELIMITER = '"';

        public override string CreateParameterName(int index)
        {
            return PARAM;
        }

        public override void AppendTable(StringBuilder builder, TableInfo tableInfo)
        {
            if (tableInfo.Attribute.IsFullyQualified)
            {
                builder.Append(tableInfo.Name);
            }
            else
            {
                builder.Append(DELIMITER);
                builder.Append(tableInfo.Name);
                builder.Append(DELIMITER);
            }
        }

        public override void AppendColumn(StringBuilder builder, ColumnInfo columnInfo)
        {
            builder.Append(DELIMITER);
            builder.Append(columnInfo.Name);
            builder.Append(DELIMITER);
        }
    }
}
